<?php   // db.php
session_start();
// This file houses database-related functions.
// dbConnect function can be called with or without an argument because
// an assigned default value ("") to the $db argument in the function declaration.
// The function begins by connecting to the MySQL server using the 3 $db 
// variables and then if a database name was given it selects that database.
// If all goes well, the reference to the database connection is returned.

$dbhost = "205.178.146.76";
$dbuser = "karwebteam";
$dbpass = "SpayNeuter09";

	// Connect to the database server

function dbConnect($db="") {
	global $dbhost, $dbuser, $dbpass, $dbcnx;

// @ suppresses error messages so took it off of mysql_connect
	$dbcnx = mysql_connect($dbhost, $dbuser, $dbpass);
	//$dbcnx = mysql_pconnect($dbhost, $dbuser, $dbpass);
	if (!$dbcnx) {
		  die("Unable to connect to the database server at this time." . mysql_error() );
	  }    // end if 

	if ($db!="" and !@mysql_select_db($db) ) {
		  die( "Unable to locate the ".$db." database at this time." );
	  }    // end if

	return $dbcnx;
} 	// end function dbConnect

function dbDC($db="")
{
	mysql_close($db);
}

function getUserInfo($db="")
{
	// Name, Active and Rank Status retrieval
	$query = "SELECT \"name\", \"active\", \"board\", \"webteam\", \"cat_screener\", \"dog_screener\", \"cat_foster\", \"dog_foster\" FROM \"volunteers\"" .
"WHERE \"volunteers\".\"volunteer_id\" = '$volID']";
	$result = mysql_query($query);
	if (!$result) 
	{
		echo("<p>Error performing query: " . mysql_error() . "</p>");
		exit();
	}
	else
	{
		$result = mysql_query($query);
		$row = mysql_fetch_row($result);
		return $row;
	}
}

?>